\(\int (a+b \tan (c+d x))^3 \, dx\) [438]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 12, antiderivative size = 72 \[ \int (a+b \tan (c+d x))^3 \, dx=a \left (a^2-3 b^2\right ) x-\frac {b \left (3 a^2-b^2\right ) \log (\cos (c+d x))}{d}+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d} \]

[Out]

a*(a^2-3*b^2)*x-b*(3*a^2-b^2)*ln(cos(d*x+c))/d+2*a*b^2*tan(d*x+c)/d+1/2*b*(a+b*tan(d*x+c))^2/d

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3563, 3606, 3556} \[ \int (a+b \tan (c+d x))^3 \, dx=-\frac {b \left (3 a^2-b^2\right ) \log (\cos (c+d x))}{d}+a x \left (a^2-3 b^2\right )+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d} \]

[In]

Int[(a + b*Tan[c + d*x])^3,x]

[Out]

a*(a^2 - 3*b^2)*x - (b*(3*a^2 - b^2)*Log[Cos[c + d*x]])/d + (2*a*b^2*Tan[c + d*x])/d + (b*(a + b*Tan[c + d*x])
^2)/(2*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3563

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((a + b*Tan[c + d*x])^(n - 1)/(d*(n - 1))
), x] + Int[(a^2 - b^2 + 2*a*b*Tan[c + d*x])*(a + b*Tan[c + d*x])^(n - 2), x] /; FreeQ[{a, b, c, d}, x] && NeQ
[a^2 + b^2, 0] && GtQ[n, 1]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {b (a+b \tan (c+d x))^2}{2 d}+\int (a+b \tan (c+d x)) \left (a^2-b^2+2 a b \tan (c+d x)\right ) \, dx \\ & = a \left (a^2-3 b^2\right ) x+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d}+\left (b \left (3 a^2-b^2\right )\right ) \int \tan (c+d x) \, dx \\ & = a \left (a^2-3 b^2\right ) x-\frac {b \left (3 a^2-b^2\right ) \log (\cos (c+d x))}{d}+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.25 (sec) , antiderivative size = 79, normalized size of antiderivative = 1.10 \[ \int (a+b \tan (c+d x))^3 \, dx=\frac {(i a-b)^3 \log (i-\tan (c+d x))-(i a+b)^3 \log (i+\tan (c+d x))+6 a b^2 \tan (c+d x)+b^3 \tan ^2(c+d x)}{2 d} \]

[In]

Integrate[(a + b*Tan[c + d*x])^3,x]

[Out]

((I*a - b)^3*Log[I - Tan[c + d*x]] - (I*a + b)^3*Log[I + Tan[c + d*x]] + 6*a*b^2*Tan[c + d*x] + b^3*Tan[c + d*
x]^2)/(2*d)

Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.01

method result size
norman \(\left (a^{3}-3 a \,b^{2}\right ) x +\frac {b^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {3 a \,b^{2} \tan \left (d x +c \right )}{d}+\frac {b \left (3 a^{2}-b^{2}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(73\)
derivativedivides \(\frac {\frac {b^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{2}+3 a \,b^{2} \tan \left (d x +c \right )+\frac {\left (3 a^{2} b -b^{3}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (a^{3}-3 a \,b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(74\)
default \(\frac {\frac {b^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{2}+3 a \,b^{2} \tan \left (d x +c \right )+\frac {\left (3 a^{2} b -b^{3}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (a^{3}-3 a \,b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(74\)
parallelrisch \(\frac {2 a^{3} d x -6 a \,b^{2} d x +b^{3} \left (\tan ^{2}\left (d x +c \right )\right )+3 \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a^{2} b -\ln \left (1+\tan ^{2}\left (d x +c \right )\right ) b^{3}+6 a \,b^{2} \tan \left (d x +c \right )}{2 d}\) \(79\)
parts \(a^{3} x +\frac {b^{3} \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}+\frac {3 a \,b^{2} \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {3 a^{2} b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(83\)
risch \(3 i a^{2} b x -i b^{3} x +a^{3} x -3 a \,b^{2} x +\frac {6 i b \,a^{2} c}{d}-\frac {2 i b^{3} c}{d}+\frac {2 b^{2} \left (3 i a \,{\mathrm e}^{2 i \left (d x +c \right )}+b \,{\mathrm e}^{2 i \left (d x +c \right )}+3 i a \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}-\frac {3 b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) a^{2}}{d}+\frac {b^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(140\)

[In]

int((a+b*tan(d*x+c))^3,x,method=_RETURNVERBOSE)

[Out]

(a^3-3*a*b^2)*x+1/2*b^3*tan(d*x+c)^2/d+3*a*b^2*tan(d*x+c)/d+1/2*b*(3*a^2-b^2)/d*ln(1+tan(d*x+c)^2)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 71, normalized size of antiderivative = 0.99 \[ \int (a+b \tan (c+d x))^3 \, dx=\frac {b^{3} \tan \left (d x + c\right )^{2} + 6 \, a b^{2} \tan \left (d x + c\right ) + 2 \, {\left (a^{3} - 3 \, a b^{2}\right )} d x - {\left (3 \, a^{2} b - b^{3}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right )}{2 \, d} \]

[In]

integrate((a+b*tan(d*x+c))^3,x, algorithm="fricas")

[Out]

1/2*(b^3*tan(d*x + c)^2 + 6*a*b^2*tan(d*x + c) + 2*(a^3 - 3*a*b^2)*d*x - (3*a^2*b - b^3)*log(1/(tan(d*x + c)^2
 + 1)))/d

Sympy [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.31 \[ \int (a+b \tan (c+d x))^3 \, dx=\begin {cases} a^{3} x + \frac {3 a^{2} b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 a b^{2} x + \frac {3 a b^{2} \tan {\left (c + d x \right )}}{d} - \frac {b^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {b^{3} \tan ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tan {\left (c \right )}\right )^{3} & \text {otherwise} \end {cases} \]

[In]

integrate((a+b*tan(d*x+c))**3,x)

[Out]

Piecewise((a**3*x + 3*a**2*b*log(tan(c + d*x)**2 + 1)/(2*d) - 3*a*b**2*x + 3*a*b**2*tan(c + d*x)/d - b**3*log(
tan(c + d*x)**2 + 1)/(2*d) + b**3*tan(c + d*x)**2/(2*d), Ne(d, 0)), (x*(a + b*tan(c))**3, True))

Maxima [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 78, normalized size of antiderivative = 1.08 \[ \int (a+b \tan (c+d x))^3 \, dx=a^{3} x - \frac {3 \, {\left (d x + c - \tan \left (d x + c\right )\right )} a b^{2}}{d} - \frac {b^{3} {\left (\frac {1}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right )^{2} - 1\right )\right )}}{2 \, d} + \frac {3 \, a^{2} b \log \left (\sec \left (d x + c\right )\right )}{d} \]

[In]

integrate((a+b*tan(d*x+c))^3,x, algorithm="maxima")

[Out]

a^3*x - 3*(d*x + c - tan(d*x + c))*a*b^2/d - 1/2*b^3*(1/(sin(d*x + c)^2 - 1) - log(sin(d*x + c)^2 - 1))/d + 3*
a^2*b*log(sec(d*x + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 543 vs. \(2 (70) = 140\).

Time = 0.58 (sec) , antiderivative size = 543, normalized size of antiderivative = 7.54 \[ \int (a+b \tan (c+d x))^3 \, dx=\frac {2 \, a^{3} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 6 \, a b^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 3 \, a^{2} b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 4 \, a^{3} d x \tan \left (d x\right ) \tan \left (c\right ) + 12 \, a b^{2} d x \tan \left (d x\right ) \tan \left (c\right ) + b^{3} \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 6 \, a^{2} b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - 2 \, b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - 6 \, a b^{2} \tan \left (d x\right )^{2} \tan \left (c\right ) - 6 \, a b^{2} \tan \left (d x\right ) \tan \left (c\right )^{2} + 2 \, a^{3} d x - 6 \, a b^{2} d x + b^{3} \tan \left (d x\right )^{2} + b^{3} \tan \left (c\right )^{2} - 3 \, a^{2} b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) + b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) + 6 \, a b^{2} \tan \left (d x\right ) + 6 \, a b^{2} \tan \left (c\right ) + b^{3}}{2 \, {\left (d \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, d \tan \left (d x\right ) \tan \left (c\right ) + d\right )}} \]

[In]

integrate((a+b*tan(d*x+c))^3,x, algorithm="giac")

[Out]

1/2*(2*a^3*d*x*tan(d*x)^2*tan(c)^2 - 6*a*b^2*d*x*tan(d*x)^2*tan(c)^2 - 3*a^2*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*
tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2 + b^3*log(4*(tan(d
*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2
 - 4*a^3*d*x*tan(d*x)*tan(c) + 12*a*b^2*d*x*tan(d*x)*tan(c) + b^3*tan(d*x)^2*tan(c)^2 + 6*a^2*b*log(4*(tan(d*x
)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*tan(c) - 2*b
^3*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(
d*x)*tan(c) - 6*a*b^2*tan(d*x)^2*tan(c) - 6*a*b^2*tan(d*x)*tan(c)^2 + 2*a^3*d*x - 6*a*b^2*d*x + b^3*tan(d*x)^2
 + b^3*tan(c)^2 - 3*a^2*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^
2 + tan(c)^2 + 1)) + b^3*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2
 + tan(c)^2 + 1)) + 6*a*b^2*tan(d*x) + 6*a*b^2*tan(c) + b^3)/(d*tan(d*x)^2*tan(c)^2 - 2*d*tan(d*x)*tan(c) + d)

Mupad [B] (verification not implemented)

Time = 5.37 (sec) , antiderivative size = 106, normalized size of antiderivative = 1.47 \[ \int (a+b \tan (c+d x))^3 \, dx=\frac {b^3\,{\mathrm {tan}\left (c+d\,x\right )}^2}{2\,d}+\frac {\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )\,\left (\frac {3\,a^2\,b}{2}-\frac {b^3}{2}\right )}{d}+\frac {3\,a\,b^2\,\mathrm {tan}\left (c+d\,x\right )}{d}-\frac {a\,\mathrm {atan}\left (\frac {a\,\mathrm {tan}\left (c+d\,x\right )\,\left (a^2-3\,b^2\right )}{3\,a\,b^2-a^3}\right )\,\left (a^2-3\,b^2\right )}{d} \]

[In]

int((a + b*tan(c + d*x))^3,x)

[Out]

(b^3*tan(c + d*x)^2)/(2*d) + (log(tan(c + d*x)^2 + 1)*((3*a^2*b)/2 - b^3/2))/d + (3*a*b^2*tan(c + d*x))/d - (a
*atan((a*tan(c + d*x)*(a^2 - 3*b^2))/(3*a*b^2 - a^3))*(a^2 - 3*b^2))/d